#include <iostream>
#include <string>
#include <sstream>

using std::cout;
using std::string;
using std::ostringstream;
using std::istringstream;
using std::endl;

template<typename T>
string NumberToString(T Number)
{
    ostringstream oss;
    oss << Number;
    return oss.str();
}

template<typename T>
T StringToNumber(const string& text)
{
    istringstream iss(text);
    T result;
    return iss >> result ? result : 0;
}

int main()
{
    string s = "123.456";
    double d = 456.789;
    
    double dd = StringToNumber<double>(s);
    string ss = NumberToString(d);

    cout << dd << endl;
    cout << ss << endl;

    return 0;
}

